﻿using UnityEngine;
using System.Collections;

public class labelScore : MonoBehaviour {

    public GUIStyle myStyleLabel;
    public HSController controller;
    public int alignX;
    public int alignY;
    public int alignSecondY;
    public int xShare;
    public int yShare;
    public int xAgain;
    public int yAgain;
    public int xMenu;
    public int yMenu;
	

	
	// Use this for initialization
	void Start () {}
	
	// Update is called once per frame
	void Update () {}

    void OnGUI()
    {
        controller = GetComponent<HSController>();
        AutoResize(480, 320);
        //AutoResize(Screen.width, Screen.height);
		GM.SetHighscore();
		
		
      /*  GUI.Label(new Rect(Screen.width/10*4, Screen.height/100*17, 10, 10), "Score:" + GM.LastScore, myStyleLabel);
        GUI.Label(new Rect(Screen.width/10*4, Screen.height/100*23, 10, 10), "Highscore:" + GM.GetHighscore(), myStyleLabel);
        GUI.Label(new Rect(Screen.width/100*25, Screen.height/100*45, 10, 10), "Jaa tulos", myStyleLabel);
        GUI.Label(new Rect(Screen.width/100*62, Screen.height/100*45, 10, 10), "Pelaa uudelleen", myStyleLabel);
        GUI.Label(new Rect(Screen.width/100*49, Screen.height/100*70, 10, 10), "Valikkoon", myStyleLabel);
  */
		//GUIText again = (GUIText) GameObject.FindGameObjectWithTag("again");
	
        GUI.Label(new Rect(alignX, alignY, 10, 10), "   Score:" + GM.LastScore, myStyleLabel);
        GUI.Label(new Rect(alignX, alignSecondY, 10, 10), "Highscore:" + GM.GetHighscore(), myStyleLabel);
        //only show if user has loggedin to facebook
		GameObject labelShare =GameObject.FindGameObjectWithTag("share");
		if(labelShare.renderer.enabled){
			GUI.Label(new Rect(xShare, yShare, 10, 10), "   Jaa tulos \n"+"Facebookissa", myStyleLabel);
		}
		GUI.Label(new Rect(xAgain, yAgain, 10, 10), "   Pelaa \n"+"uudelleen", myStyleLabel);
		GUI.Label(new Rect(xMenu, yMenu, 10, 10), "Valikkoon", myStyleLabel);
        //stringToEdit = GUI.TextField(new Rect(10, 10, 200, 20), stringToEdit, 25);
        //if (GUI.Button(new Rect(alignFirstX, alignFirstY, width, height), "Play Again", myStyleButton))
        //{
        //    Application.LoadLevel("Spaceship");
        //}
        //if (GUI.Button(new Rect(alignFirstX, alignSecondY, width, height), "Menu", myStyleButton))
        //{
        //    Application.LoadLevel("Menu");
        //}
        //if (GUI.Button(new Rect(alignFirstX, alignThirdY, width, height), "Share", myStyleButton))
        //{
        //    StartCoroutine(controller.PostScores("Matti",PlayerPrefs.GetInt("Score")));
        //}
    }
    public static void AutoResize(int screenWidth, int screenHeight)
    {
        Vector2 resizeRatio = new Vector2((float)Screen.width / screenWidth, (float)Screen.height / screenHeight);
        GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(resizeRatio.x, resizeRatio.y, 1.0f));
    }
}
